<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>
<body>
    



    <td>
        触发后，将在角色周围产生至多存在10秒的「种识之叶」。
        拾取种识之叶的角色元素精通提升
        <color=#99ffffff>60点，持续12秒。每20秒至多通过这种方式产生一枚种识之叶。角色处于队伍后台时也能触发。
    </color=#99ffffff></td>


    <script>
        let charaters = {
            units : {
                name: "战力单位",
                base: 300,
                criticalRate: 5 + 20,
                criticalStrike: 50,
                attRate:18 + 20,
                dmgRate:15 + 30
            }
        }

        let weapons = {
            jielv: {
                name:"lv90磐岩结绿(23000血)",
                base: 542,
                criticalRate: 44.1,
                fixedAtt: 552
            },
            humo: {
                name:"lv90护摩(25000血)生命在50%以下",
                base: 608,
                criticalStrike: 66.2,
                fixedAtt: 850
            },
            humo100: {
                name:"lv90护摩(25000血)生命在50%以上",
                base: 608,
                criticalStrike: 66.2,
                fixedAtt: 400
            },
            qy: {
                name:"lv90千岩大剑离月队",
                base: 510,
                criticalRate: 24,
                attRate: 56 + 41.3,
            },
            qyq: {
                name:"lv90千岩枪离月队",
                base: 565,
                criticalRate: 24,
                attRate: 56 + 27.6,
            },
            dunjian: {
                name: "lv90盾系列叠满套盾",
                base:608,
                attRate: 49.6 + 80,
            },
            juexian: {
                name:"lv90绝弦", 
                base: 510,
                dmgRate:48,
                "精通":165
            },
            tk: {
                name:"lv90天空弓(不考虑物理特效)",  
                base: 674,
                criticalRate: 22.1,
                criticalStrike:40
            },
            tks: {
                name:"lv90天空书(不考虑物理特效)",  
                base: 674,
                attRate:33.1,
                dmgRate: 24
            },
            gongzang: {
                name:"lv90弓藏",
                base: 510,
                attRate:41.3,
                dmgRate:80
            },
            lvqiang: {
                name:"lv90绿枪叠满",
                base: 674,
                criticalRate: 22.1,
                attRate: 42,
                dmgRate: 24
            },
            langmoyBuff: { 
                name:"lv90狼末有buff",
                base: 608,
                attRate: 49.6 + 40 + 80
            },
            langmoBuff: { 
                name:"lv90狼末无buff",
                base: 608,
                attRate: 49.6 + 40
            },
            sifeng: {
                name:"lv90四风叠满",
                base: 608,
                criticalRate: 33.1,
                dmgRate:64
            },
            amosi: {
                name: "lv90阿莫斯叠满",  // 24增伤
                base: 608,
                attRate:49.6,
                dmgRate:104
            },
            cg:{
                name:"lv90骨剑",
                base: 510,
                criticalRate: 27.6,
                dmgRate:50
            },
            hj:{
                name:"lv90黑剑",  // 普攻重击40增伤
                base: 510,
                criticalRate: 27.6,
                dmgRate:40
            },
            xlly: {
                name:"lv90匣里龙吟",  // 敌人火雷元素附着下增伤36
                base: 510,
                attRate: 41.3,
                dmgRate:36
            },
            jd : {
                name:"lv90决斗",
                base: 454,
                criticalRate: 36.8,
                attRate: 48
            },
            mc : {
                name:"lv90灭辰",
                base: 454,
                精通: 221,
                dmgRate: 36
            },
        }
        let normal_clips = calc_clips_att();
        let normal_clips2 = calc_clips_att(2);
        let normal_clips_jt = calc_clips_jt();
        let normal_clips_jt2 = calc_clips_jt(2);

        calc()

        function getDMG(dataarr, getRet){
            let chance = 25;
            let _ret = [];
            for (let index = 0; index <= chance; index++) {
                let criticalStrike = index; 
                for (let index2 = 0; index2 <= chance - index; index2++) {
                    let criticalRate = index2;
                    for (let index3 = 0; index3 <= chance-index-index2; index3++) {
                        let attRate = index3;
                        let defenceRate = chance - index - index2 - index3;
                        _ret.push({
                            精通: 23 * defenceRate,
                            attRate:5.8 * attRate,
                            criticalRate:3.9 * criticalRate,
                            criticalStrike:7.8 * criticalStrike
                        });
                    }
                }
            }
            _ret = _ret.map(second => {
                let panel = getPanel([...dataarr, second]);
                return  getRet(panel, second)
            })
            _ret.sort((b,a)=> a.point-b.point)
            return _ret[0]
        }
        function getDmgDps(data, rate=1, rea){
            let criticalRate = data.criticalRate
            if(criticalRate > 100){criticalRate = 100}
            let baseat = data.base * (1 + data.attRate/100) + data.fixedAtt;
            let bdmg = baseat * (1 + data.criticalStrike/100);
            let bdps = (criticalRate * 10 * bdmg + (1000-criticalRate * 10)*baseat)/1000
            let adddmg = bdps * (1 + data.dmgRate/100)
            if(rea){
                let {精通, 系数, 精通增伤} = rea
                let tmp = 1 + 精通增伤 + jt(精通);
                return adddmg * rate * 系数 * tmp
            }
            return adddmg * rate
        }
        function getPanel(arr){
            let info = {name1:"",name2:""};
            arr.forEach((item, i)=>{
                if(item.name){
                    info["name" + (i+1)] = item.name
                }
                for (const key in item) {
                    if(key !== "name"){
                        if(info[key]){
                            info[key] += item[key]
                        } else {
                            info[key] = item[key]
                        }
                    }
                }
            })
            return info
        }
        function q (resistance) {
            if(resistance < 0) {
                return 1 - resistance/200
            } else if (resistance >=0 && resistance < 75){
                return 1 - resistance/100
            } else {
                return 1/(1+resistance/100*4)
            }
        }
        function df(youLv=0, eLv=0, td){
            return (100+youLv)/(100+youLv+(100+eLv)*(td? (100-td)/100 : 1))
        }
        // 固定攻击力 19  防御力23 生命值299 5.3% 
        function calc_clips_jt (n) {
            let clips = [
                {
                    精通:23,
                    attRate: 5.8,
                    criticalRate: 3.9,
                    criticalStrike:7.8
                },
                {
                    精通:23,
                    attRate: 5.8,
                    criticalRate: 3.9,
                    criticalStrike:7.8
                },
                {
                    精通:23,
                    fixedAtt:19,
                    criticalRate: 3.9,
                    criticalStrike:7.8
                },
                {
                    精通:23,
                    attRate: 5.8,
                    criticalRate: 3.9,
                    criticalStrike:7.8
                },
                {
                    精通:23,
                    attRate: 5.8,
                    criticalRate:n!=2? 0:3.9,
                    criticalStrike:n!=2? 7.8:0
                }
            ]
            let data = {}
            clips.forEach(item => {
                for (const key in item) {
                    data[key] = data[key]? (data[key]+item[key]) : item[key]
                }
            })
            return data
        }
        function calc_clips_att (n) {
            let clips = [
                {
                    fixedAtt:19,
                    attRate: 5.8,
                    criticalRate: 3.9,
                    criticalStrike:7.8
                },
                {
                    fixedAtt:19,
                    attRate: 5.8,
                    criticalRate: 3.9,
                    criticalStrike:7.8
                },
                {
                    fixedAtt:19,
                    criticalRate: 3.9,
                    criticalStrike:7.8
                },
                {
                    fixedAtt:19,
                    attRate: 5.8,
                    criticalRate: 3.9,
                    criticalStrike:7.8
                },
                {
                    fixedAtt:19,
                    attRate: 5.8,
                    criticalRate:n!=2? 0:3.9,
                    criticalStrike:n!=2? 7.8:0
                }
            ]
            let data = {}
            clips.forEach(item => {
                for (const key in item) {
                    data[key] = data[key]? (data[key]+item[key]) : item[key]
                }
            })
            return data
        }
        function jt(k){
            if(k == 0){return 0}
            return Math.log(0.99316499 + 0.00209988607 * k + 0.0000001213236971*k*k)
        }

        function calc() {
            let charactersDmg = []
            Object.values(weapons).forEach(weapon => {
                charactersDmg.push(getDMG([charaters.units,weapon,{fixedAtt:311,criticalStrike:62.2,dmgRate:46.6,attRate:46.6},normal_clips2], (data,second) => {
                
                    let attack = data.base *(1 + data.attRate/100) + data.fixedAtt
                    let rea = { 精通:data.精通, 系数:1.5, 精通增伤:0 };
                    let point = getDmgDps(data, 1) * q(10) * df(90,90);  // 
                    let pointRea = getDmgDps(data, 1,rea) * q(10) * df(90,90);  // 
                
                    let ret = point * 4 + pointRea * 1
                    return {point:ret, data, second, attack ,得分:point,反应得分:pointRea}
                }))
            })
            
            charactersDmg.sort((a,b)=>b.point-a.point);
            console.log(charactersDmg);
            console.log(charactersDmg.map(v=>{
                return  `反应比1:4总得分: ${v.data.name2} : ${v.point}   单次得分 ${v.得分} 单次反应得分${v.反应得分}`
            }));
        }







    </script>
</body>
</html>